{{include file="header_inc.html"}}
<script type="text/javascript">
$(document).ready(function() {
	//日期选择控件
	Calendar.setup({
		weekNumbers: true,
	    inputField : "createtime",
	    trigger    : "createtime",
	    dateFormat: "%Y-%m-%d %H:%M:%S",
	    showTime: true,
	    minuteStep: 1,
	    onSelect   : function() {this.hide();}
	});
	
	//来源选择
	$("#copyfrom_data").change(function(){
		var copyfrom_data = $(this).val();
		if(copyfrom_data != 0) {
			$("#copyfrom").val(copyfrom_data);
		}
	}),
	
	CKEDITOR.replace( 'content',{height:300,pages:true,subtitle:true,textareaid:'content',module:'content',catid:'{{$id}}',
		filebrowserUploadUrl : '/content/manage/attachment/upload/content/catid/{{$id}}/dosubmit/1/',
		upload:true,
		toolbar :
		[
		['Source','-','Templates'],
				    ['Cut','Copy','Paste','PasteText','PasteFromWord','-','Print'],
				    ['Undo','Redo','-','Find','Replace','-','SelectAll','RemoveFormat'],['ShowBlocks'],['Image','Capture','Flash'],['Maximize'],
				    '/',
				    ['Bold','Italic','Underline','Strike','-'],
				    ['Subscript','Superscript','-'],
				    ['NumberedList','BulletedList','-','Outdent','Indent','Blockquote'],
				    ['JustifyLeft','JustifyCenter','JustifyRight','JustifyBlock'],
				    ['Link','Unlink','Anchor'],
				    ['Table','HorizontalRule','Smiley','SpecialChar','PageBreak'],
				    '/',
				    ['Styles','Format','Font','FontSize'],
				    ['TextColor','BGColor'],
				    ['attachment'],
		]
		});
})
</script>

<body>
	<form name="myform" id="myform" action="/content/manage/edit/"
		method="post" enctype="multipart/form-data">
		<input name="id" type="hidden" value="{{$id}}">
		<div class="addContent">
			<div class="crumbs">当前位置：内容 &gt; 内容发布管理 &gt; 添加内容</div>
			<div class="col-right">
				<div class="col-1">
					<div class="content pad-6">

						<h6>缩略图</h6>
						<div class='upload-pic img-wrap'>
							<input type='hidden' name='info[news_img]' id='news_img' value=''>
							<a href='javascript:void(0);'
								onclick="upload('thumb_images', '附件上传','news_img');return false;">
								<img
								src='{{if $News_Info.news_img}}{{#siteUploadPath#}}/content/{{$News_Info.news_img}}{{else}}{{#siteImgPath#}}/icon/upload-pic.png{{/if}}'
								id='thumb_preview' width='135' height='113' style='cursor: hand' />
							</a>
						</div>

						<h6>相关文章</h6>
						<input type='hidden' name='info[relation]' id='relation'
							value='{{$News_Info.relation}}' style=''>
						<ul class="list-dot" id="relation_text">
							{{if $News_Info.relation_info}} {{foreach item=content
							from=$News_Info.relation_info}}
							<li id="v{{$content.id}}">·<span>{{$content.title}}</span><a
								onclick="remove_relation('v{{$content.id}}',{{$content.id}})"
								class="close" href="javascript:;"></a></li> {{/foreach}} {{/if}}
						</ul>
						<div>
							<input type='button' value="添加相关"
								onclick="omnipotent('selectid','/content/manage/relationlist/modelid/{{$catid}}/','添加相关文章',1)"
								class="button" style="width: 66px;"> <span
								class="edit_content"> </span>
						</div>

						<h6>发布时间</h6>
						<input type="text" name="info[createtime]" id="createtime"
							value="{{$News_Info.createtime}}" size="21" class="date" readonly>&nbsp;

						<h6>允许评论</h6>
						<label class="ib" style="width: 88px"> <input type="radio"
							name='info[allow_comment]' id="allow_comment_1"
							{{if $News_Info.allow_comment==1}}checked{{/if}} value="1">允许评论
						</label> <label class="ib" style="width: 88px"> <input
							type="radio" name='info[allow_comment]' id="allow_comment_0"
							{{if $News_Info.allow_comment==0}}checked{{/if}} value="0">不允许评论
						</label>

						<h6>是否置顶</h6>
						<label class="ib" style="width: 88px"> <input type="radio"
							name='info[istop]' id="allow_istop_1"
							{{if $News_Info.istop==1}}checked{{/if}} value="1">置顶
						</label> <label class="ib" style="width: 88px"> <input
							type="radio" name='info[istop]' id="allow_istop_0"
							{{if $News_Info.istop==0}}checked{{/if}} value="0">不置顶
						</label>

						<h6>状态</h6>
						<label class="ib" style="width: 88px"> <input type="radio"
							name='info[status]' id="allow_status_1"
							{{if $News_Info.status==1}}checked{{/if}} value="1">发布
						</label> <label class="ib" style="width: 88px"> <input
							type="radio" name='info[status]' id="allow_status_0"
							{{if $News_Info.status==0}}checked{{/if}} value="0">不允许发布
						</label>
					</div>
				</div>
			</div>
			<div class="col-auto">

				<div class="col-1">
					<div class="content pad-6">
						<table width="100%" cellspacing="0" class="table_form">
							<tbody>
								<tr>
									<th width="80"><font color="red">*</font> 栏目</th>
									<td><input type="hidden" name="info[catid]"
										value="{{$catid}}">{{$catname}}</td>
								</tr>
								<tr>
									<th width="80"><font color="red">*</font> 标题</th>
									<td><input type="text" style="width: 400px;"
										name="info[title]" id="title" value="{{$News_Info.title}}"
										style="color:" class="measure-input "
										onBlur="$.post('/content/manage/getkeywords/'+Math.random(), {title:$('#title').val()}, function(data){if(data && $('#keywords').val()=='') $('#keywords').val(data); })"
										onkeyup="strlen_verify(this, 'title_len', 80);" /> <input
										type="hidden" name="info[style_color]" id="style_color"
										value=""> <input type="hidden"
										name="info[style_font_weight]" id="style_font_weight" value=""><input
										type="button" class="button" id="check_title_alt" value="检测重复"
										onclick="$.post('/content/manage/checktitle/', {catid:{{$id}},title:$('#title').val()}, function(data){if(data=='1') {$('#check_title_alt').val('标题重复');$('#check_title_alt').css('background-color','#FFCC66');} else if(data=='0') {$('#check_title_alt').val('标题不重复');$('#check_title_alt').css('background-color','#F8FFE1')}})"
										style="width: 73px;" /><img
										src="{{#siteImgPath#}}/icon/colour.png" title="设置标题颜色"
										width="15" height="16"
										onclick="colorpicker('title_colorpanel','set_title_color');"
										style="cursor: hand" /> <img
										src="{{#siteImgPath#}}/icon/bold.png" width="10" height="10"
										onclick="input_font_bold()" style="cursor: hand"
										title="标题是否加粗" /> <span id="title_colorpanel"
										style="position: absolute;" class="colorpanel"></span>还可输入<B><span
											id="title_len">80</span></B> 个字符</td>

								</tr>
								<tr>
									<th width="80">关键词</th>
									<td><input type='text' name='info[keywords]' id='keywords'
										value='{{$News_Info.keywords}}' style='width: 280px'
										class='input-text'> 多关键词之间用空格或者“,”隔开</td>
								</tr>
								<tr>
									<th width="80">来源</th>
									<td><input type='text' id="copyfrom" name='info[copyfrom]'
										value='{{$News_Info.copyfrom}}' style='width: 400px;'
										class='input-text'> <select name='copyfrom_data'
										id="copyfrom_data">
											<option value="0" selected>≡请选择≡</option> {{foreach
											item=content from=$Copyfrom_list}}
											<option value="{{$content.sitename}}" selected>{{$content.sitename}}</option>
											{{/foreach}}
									</select></td>
								</tr>
								<tr>
									<th width="80">摘要</th>
									<td><textarea name='info[description]' id='description'
											style='width: 98%; height: 46px;'
											onkeyup="strlen_verify(this, 'description_len', 255)">{{$News_Info.description}}</textarea>还可输入<B><span
											id="description_len">255</span></B> 个字符</td>

								</tr>
								<tr>
									<th width="80"><font color="red">*</font> 内容</th>
									<td>
										<div id='content_tip'></div> <textarea name="info[content]"
											id="content" boxid="content">{{$News_Info.content}}</textarea>
										<div class='editor_bottom'>
											<div id='page_title_div'>
												<table cellpadding='0' cellspacing='1' border='0'>
													<tr>
														<td class='title'>子标题<span id='msg_page_title_value'></span></td>
														<td><a class='close' href='javascript:;'
															onclick='javascript:$("#page_title_div").hide();'><span>×</span></a></td>
													</tr>
													<tr>
														<td colspan='2'><input name='page_title_value'
															id='page_title_value' class='input-text' value=''
															size='30'>&nbsp; <input type='button'
															class='button' value='提交'
															onclick='insert_page_title("content",1)'></td>
													</tr>
												</table>
											</div>
										</div>
										<div class="content_attr">
											<label><input name="add_introduce" type="checkbox"
												value="1">是否截取内容</label><input type="text"
												name="introcude_length" value="200" size="3">字符至内容摘要
											<label><input type='checkbox' name='auto_thumb'
												value="1">是否获取内容第</label><input type="text"
												name="auto_thumb_no" value="1" size="2" class="">张图片作为标题图片
										</div>
									</td>
								</tr>
								<tr>
									<th width="80">分页方式</th>
									<td><select name="info[pagetype]" id="pagetype"
										onchange="if(this.value==1)$('#paginationtype1').css('display','');else $('#paginationtype1').css('display','none');">
											<option {{if $News_Info.pagetype==0}}checked{{/if}} value="0">不分页</option>
											<option {{if $News_Info.pagetype==1}}checked{{/if}} value="1">自动分页</option>
											<option {{if $News_Info.pagetype==2}}checked{{/if}} value="2">手动分页</option>
									</select> <span id="paginationtype1" style="display: none"><input
											name="info[maxcharperpage]" type="text" id="maxcharperpage"
											value="10000" size="8" maxlength="8">字符数（包含HTML标记） </span></td>
								</tr>
							</tbody>
						</table>
					</div>
				</div>
			</div>

		</div>

		<div class="fixed-bottom">
			<div class="fixed-but text-c">
				<div class="button">
					<input value="保存后自动关闭" type="submit" name="dosubmit" class="cu"
						style="width: 145px;" onclick="refersh_window()">
				</div>
				<div class="button">
					<input value="保存并继续发表" type="submit" name="dosubmit_continue"
						class="cu" style="width: 130px;" title="Alt+X"
						onclick="refersh_window()">
				</div>

				<div class="button">
					<input value="关闭(X)" type="button" name="close"
						onclick="refersh_window();close_window();" class="cu"
						style="width: 70px;">
				</div>
			</div>
		</div>
	</form>

</body>
</html>
<script type="text/javascript">//只能放到最下面
$(function(){
	$.formValidator.initConfig(
	{
		formid:"myform",autotip:true,
		onerror:function(msg,obj){
			window.top.art.dialog(
					{
						id:'check_content_id',
						content:msg,
						lock:true,
						width:'200',
						height:'50'
					},
	function(){
		$(obj).focus();
		boxid = $(obj).attr('id');
		if($('#'+boxid).attr('boxid')!=undefined) {
			check_content(boxid);
		}
	})
	}}
	);
	$("#title").formValidator({onshow:"",onfocus:"请输入标题"}).inputValidator({min:1,max:80,onerror:"标题不能为空"});
	$("#content").formValidator({onshow:"",onfocus:"内容不能为空"}).functionValidator({
	    fun:function(val,elem){
			var oEditor = CKEDITOR.instances.content;
			var data = oEditor.getData();
	        if($('#islink').attr('checked')){
			    return true;
		    } else if(($('#islink').attr('checked')==false) && (data=='')){
			    return "内容不能为空";
		    } else if (data=='' || $.trim(data)=='') {
				return "内容不能为空";
			}
			return true;
		}
	});	
	
	$('.edit_content').hide();
	jQuery(document).bind('keydown', 'Alt+x', function (){close_window();});
})
document.title='添加内容';
self.moveTo(-4, -4);
function refersh_window() {
	setcookie('refersh_time', 1);
}
</script>
{{include file="footer.html"}}
